/**
 * 挖掘发布控制类
 */
function MinePublishController(){
	
	//当前分析主题ID
	var analyseId = window[constant.ANALYSE_ID];
	var publishObjService = new MinePublishObjController(analyseId);
	var publishConfigService = new MinePublishConfigController(analyseId);
	var publishJobService = new MinePublishJobController(analyseId);
	var publishService = new MinePublishServiceController(analyseId);
	
	/**
	 * 加载当前分析主题下的所有流程信息
	 */
	var loadAnalyseThemeAll = function(){
		$.ajax({
			url:contextPath+"/api/ai/mine/loadAllAnalyseInfo?time=" + new Date().getTime(),
			data:{
				analyseId: analyseId
			},
			dataType:'json',
			type:'post',
			success:function(result){
				publishObjService.initAllFlowGrid(result); 
			}
		});
	}
	/**
	 * 加载当前分析主题下的所有发布资源
	 */
	var loadPublishs = function(){
		$.ajax({
			url:contextPath+"/api/ai/mine/publish/listPublish?time=" + new Date().getTime(),
			data:{
				themeId: analyseId
			},
			dataType:'json',
			type:'post',
			success:function(result){
				publishObjService.initPublishFlowGrid(result); 
			}
		});
	}
	
	
	var bindEvent = function(){
		$('#tempo-mine-publishobj-btn').unbind('click').bind('click',function(){
			$('.publish-menu').removeClass('selected');
			$(this).addClass('selected');
			publishConfigService.hide();
			$('#publish-mine-layout').show();
			loadAnalyseThemeAll();
			loadPublishs();
		});
		
		$('#tempo-mine-publishconfig-btn').unbind('click').bind('click',function(){
			$('.publish-menu').removeClass('selected');
			$(this).addClass('selected');
			publishConfigService.initOrShowTab();
			publishJobService.initOrrefresh()
		});
	}
	
	!function() {
		loadAnalyseThemeAll();
		loadPublishs();
		bindEvent();
	}();
}
